# 作者：要努力，努力，再努力
# 开发时间：2022/4/28 21:51

def findAnswer(question):
    with open('answer.txt', 'r', encoding='utf-8') as rfile:
        while True:
            line = rfile.readline()
            if line:
                keyword = line.split('|')[0]
                reply = line.split('|')[1]
                if keyword in question:
                    return reply
            else: # 到最后一行了
                return False
    return False


if __name__ == '__main__':
    while True:
        question = input('请输入：')
        if question:
            reply = findAnswer(question)
            if reply:
                print(reply, end='')
            else:
                last = input('不懂，输入是否退出系统？y/n')
                if last == 'y':
                    break
                else:
                    continue
        else:
            print('没有输入信息')
            continue
        last = input('输入是否退出系统？y/n')
        if last == 'y':
            break
        else:
            continue
